﻿using System;
using System.Collections;
using System.Collections.Generic;
using Gp.Scripts.GUI;
using Gp.Scripts.Core;


namespace Gp.Scripts.Data
{
    /// <summary>
    /// 专长
    /// </summary>
    [Serializable]
    public abstract class BaseSpecialty : IBonusProvider, ILogicEntity
    {
        protected BaseUnit Unit;

        public readonly BaseSpecialtyEntityConfig EntityConfig;

        protected BaseSpecialty(BaseSpecialtyEntityConfig config)
        {
            EntityConfig = config;
        }


        public void Init(BaseUnit unit)
        {
            Unit = unit;
        }


        /// <summary>
        /// 当添加至某单位时触发
        /// </summary>
        public virtual void OnApply() { }


        public virtual IEnumerator OnSmallTurnStart()
        {
            yield break;
        }

        public virtual IEnumerator OnSmallTurnEnd()
        {
            yield break;
        }


        /// <summary>
        /// 当战斗开始时触发
        /// </summary>
        public virtual void OnBattleStart() { }


        /// <summary>
        /// 当战斗结束时触发
        /// </summary>
        public virtual void OnBattleEnd() { }


        public virtual IEnumerable<BonusNumber> Bonus()
        {
            return Array.Empty<BonusNumber>();
        }


        public virtual ILogicEntity GetBonusProviderInfo()
        {
            return this;
        }

        public IEntityConfig GetConfig()
        {
            return this.EntityConfig;
        }


        protected void TextEffect(string text)
        {
            TextEffect(Unit, text);
        }


        protected void TextEffect(BaseUnit unit, string text)
        {
            Global.Get<GridBattleGUISystem>().PlayFloatingText(unit, text);
        }
    }
}